package com.modelclient.app.test;

import android.os.Build;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.modelclient.app.R;
import com.modelclient.baselib.model.MineDataBean;
import com.modelclient.baselib.util.GlideUtil;

import java.util.List;


public class MineMeetAdapter extends BaseQuickAdapter<MineDataBean.HotEventItem, BaseViewHolder> {

    public MineMeetAdapter(@Nullable List<MineDataBean.HotEventItem> data) {
        super(R.layout.mine_meet_item, data);
    }

    private OnClickStatusListener clickStatusListener;

    public interface OnClickStatusListener{
        void clickStatusBtn(String eventId, int position);
    }

    public void setOnClickStatusListener(OnClickStatusListener clickStatusListener){
        this.clickStatusListener = clickStatusListener;
    }

    @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
    @Override
    protected void convert(BaseViewHolder helper, MineDataBean.HotEventItem item) {
        ImageView iv = helper.getView(R.id.iv_img);
        TextView tvTitle = helper.getView(R.id.tv_title);
        TextView tvCity = helper.getView(R.id.tv_city);
        TextView tvTime = helper.getView(R.id.tv_time);
        TextView tvStatusTxt = helper.getView(R.id.tv_status_txt);
        ImageView ivTag = helper.getView(R.id.iv_tag);
        TextView tvTag = helper.getView(R.id.tv_tag);

        if ("2".equals(item.status)){
            //进行中
            ivTag.setImageResource(R.mipmap.icon_meeting_tag);
        }else if("1".equals(item.status)){
            //预告
            ivTag.setImageResource(R.mipmap.icon_meet_pre_tag);
        }else{
            //已结束
            ivTag.setImageResource(R.mipmap.icon_meet_end_tag);
        }
        tvTag.setText(item.statusText);
        tvTitle.setText(item.name);
        tvCity.setText(item.city);
        tvTime.setText(item.eventTime);
        GlideUtil.displayRoundImage(mContext, item.image, iv, 4, R.mipmap.defaults);
        tvStatusTxt.setOnClickListener(view -> {
            clickStatusListener.clickStatusBtn(item.event_id,helper.getAdapterPosition());
        });
    }
}
